Skip to main content

Component testing - Donut chart test plan

Alt text

Subcomponents: Pie and Legend

Library used: jest and (enzyme or react testing library)

Test caseExecution stepsValidation stepsLibrary used
Test case 1: [Snapshot testing] [Component]
  • Renders donut chart with data.
Donut chart renders correctlyEnzyme
Test case 2: [Snapshot testing] [Individual Props]Renders donut chart with:
  • HideTooltip prop set to “true”.
Donut chart renders correctlyEnzyme
  • HideLegend prop set to “true”.
Donut chart renders correctlyEnzyme
  • EnabledLegendsWrapLines prop set to “true”.
Donut chart renders correctlyEnzyme
  • ValueInsideDonut set to a string / number.
Donut chart renders correctlyEnzyme
  • HideLabels prop set to "false".
Donut chart renders correctlyEnzyme
  • HideLabels prop set to "false" and ShowLabelsInPercent prop set to "true".
Donut chart renders correctlyEnzyme
Test case 3: [Specific DOM elements] Renders individual elements on a prop change:
  • HideLegend prop is set to “false”.
Legend mounts correctlyEnzyme
  • HideTootip prop is set to “false”.
Callout mounts correctlyEnzyme
  • onRenderCalloutPerStack prop is not given.
Should not render onRenderCalloutPerStackEnzyme
  • onRenderCalloutPerDataPoint prop is given.
Should render onRenderCalloutPerDataPoint correctlyEnzyme
Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events:
  • On mouse over on the donut chart.
Should render calloutEnzyme
  • On mouse move on Pie 1 (step 1) -> mouse leave (step 2) -> mouse move on Pie 2 (step 3).
Html in step 1 should not be the same as in step 3Enzyme
  • On mouse over with onRenderCalloutPerDataPoint prop provided.
Should render the custom calloutEnzyme
  • On mouse over, followed by mouse leave on callout.
On mouse over, callout should be defined, on mouse leave, callout should disappear.Enzyme
Test case 5: [Mouse events – Legends] Renders individual elements on mouse events:
  • On mouse over on legends.
Should highlight the corresponding pieRTL
  • On mouse over on legends.
Should change the value inside donut with the legend valueEnzyme
  • On click on Pie.
Should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0.RTL
  • On mouse out after mouse over on first legend.
Should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouse out.RTL
Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events:
  • On focus on a Pie.
Should render the corresponding calloutRTL
  • On blur on a Pie.
Should remove focus from the corresponding PieRTL